.message {
    display: flex;
    gap: 1rem;
    padding: 1rem;
    border-radius: 8px;
    animation: fadeIn 0.3s ease;
    max-width: 100%;
}

.user {
    background-color: var(--bg-secondary);
}

.assistant {
    background-color: var(--bg-tertiary);
}
.tool {
    background-color: var(--bg-tertiary);
}
.avatar {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--primary-color);
    color: white;
    font-size: 1.25rem;
}

.content {
    flex: 1;
    min-width: 0; /* 防止flex子项溢出 */
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.role {
    font-weight: 600;
    color: var(--primary-color);
}

.time {
    font-size: 0.875rem;
    color: var(--text-tertiary);
}

.text {
    color: var(--text-primary);
    line-height: 1.5;
    overflow-wrap: break-word;
}

/* Markdown 样式 */
.text :global(p) {
    margin: 0.5em 0;
}

.text :global(a) {
    color: var(--primary-color);
    text-decoration: none;
}

.text :global(a:hover) {
    text-decoration: underline;
}

.text :global(ul),
.text :global(ol) {
    margin: 0.5em 0;
    padding-left: 1.5em;
}

.text :global(li) {
    margin: 0.25em 0;
}

.text :global(blockquote) {
    margin: 0.5em 0;
    padding-left: 1em;
    border-left: 3px solid var(--primary-color);
    color: var(--text-secondary);
}

.text :global(code:not(pre code)) {
    padding: 0.2em 0.4em;
    background-color: var(--bg-secondary);
    border-radius: 3px;
    font-family: monospace;
    font-size: 0.9em;
}

.text :global(pre) {
    margin: 0.5em 0;
    padding: 1em;
    background-color: var(--bg-primary);
    border-radius: 4px;
    overflow-x: auto;
    border: 1px solid var(--border-color);
}

.text :global(img) {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
}

.text :global(table) {
    width: 100%;
    border-collapse: collapse;
    margin: 0.5em 0;
}

.text :global(th),
.text :global(td) {
    padding: 0.5em;
    border: 1px solid var(--border-color);
}

.text :global(th) {
    background-color: var(--bg-secondary);
    font-weight: 600;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 768px) {
    .message {
        padding: 0.75rem;
        gap: 0.75rem;
    }

    .avatar {
        width: 32px;
        height: 32px;
        font-size: 1rem;
    }

    .header {
        margin-bottom: 0.25rem;
    }

    .time {
        font-size: 0.75rem;
    }
}
